import { createSlice } from "@reduxjs/toolkit";

export const userSlice = createSlice({
  name: "user",
  initialState: {
    token: "",
    userInfo: {
      id: 0,
      username: "",
      password: "",
      tel: "",
      telCode: "",
      nickname: "",
      avatar: "",
      createTime: "",
      sex: "",
      age: 0,
    },
  },
  reducers: {
    loginSuccess(state, action) {
      state.token = action.payload.token
      state.userInfo = action.payload.userInfo
    }
  }
});

export const { loginSuccess } = userSlice.actions;
